<template>
    <div class="localLogin">
        <van-nav-bar safe-area-inset-top placeholder :title="$t('Local')" left-arrow fixed @click-left="onClickLeft">
            <template #right>
                <van-icon name="question-o" size="24" @click="openDiscription" />
            </template>
        </van-nav-bar>
        <van-tabs v-model="active" animated>
            <van-tab title="WIFI" class="padding">
                <van-form name="addSite" @submit="login">
                    <div class="registered_box">
                        <div class="registered_li">
                            <div class="registered_li_tit required">{{$t('Password')}}</div>
                            <div class="registered_li_ipt">
                                <van-field clearable name="password" v-model="password" type="text" />
                            </div>
                        </div>
                    </div>
                    <div class="tips">{{$t('Tip')}}：{{$t('LocalTipMsgWifiSet')}}( {{$t('LocalInTip')}} )</div>
                    <div class="btnBox">
                        <van-button color="linear-gradient(#F9C25F, #F5861A)" :disabled="password==''" round block native-type="submit">{{$t('Login')}}</van-button>
                    </div>
                </van-form>
            </van-tab>
            <van-tab title="蓝牙" class="padding">
                <van-cell class="list" title="大功率机" is-link to="bluetoothlist" />
            </van-tab>
        </van-tabs>
        <wifisetting ref="discriptShow"></wifisetting>
    </div>
</template>

<script>
import wifisetting from '../../components/Protocol/WifiSetting'
export default {
    components:{
        wifisetting
    },
    data() {
        return {
            password:'',
            active:''
        };
    },
    methods: {
        onClickLeft(){
            
            if(this.$route.query.from){
                this.$router.push({path:this.$route.query.from});
            }else{
                this.$router.push({path:'/login'});
            }
        },
        openDiscription(){
            this.$refs.discriptShow.openPop(true,'3');
        },
        async login(){
            this.comm.loadingShow();
            let data = await this.SETAPI.LocalIn({'optType':'newParaSetting','subOption':'pwd','Value':this.password});
            let newdata=data.substring(0,1);
            if(newdata=="Y"){
                sessionStorage.setItem('bdPwd',this.password);
                this.$router.push({path:'/local/localflow'});
            }else{
                this.comm.tipsShow('LoginFailed');
            }
        }
    },
};
</script>

<style  lang="less" scoped>
.localLogin{
    .padding{
        padding-top: 5px;
    }
    .list{
        text-align: left;
    }
  .registered_box{
    width: 100%;
    background: #ffffff;
  }
  .registered_li{
    width: 100%;
    border-bottom: 1px solid #efefef;
  }
  .registered_li_tit{
    padding: 12px 0 0 15px;
    width: 100%;
    color: #929292;
    text-align: left;
    box-sizing: border-box;
  }
  .tips{
      box-sizing: border-box;
      text-align: left;
      font-size: 14px;
      color: #fb6002;
      width: 100%;
      padding: 10px;
  }
}
</style>
